package net.zjitc.controller.admin;

import net.zjitc.pojo.Orders;
import net.zjitc.service.OrderService;
import net.zjitc.vo.OrderConditionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @AUTHOR zhj
 * @DATE 2019/3/31 13:32
 */
@Controller
@RequestMapping("/manage/order/")
public class AdminOrderController {
    @Autowired
    OrderService orderService;

    @RequestMapping("findAllOrders")
    public String findAllOrders(Model model){
        List<Orders> ordersList = orderService.findAll();
        model.addAttribute("olist",ordersList);
        return "/admin/orders/list.jsp";
    }


    @RequestMapping("findByCondition")
    @ResponseBody
    public List<Orders> findByCondition(OrderConditionVo vo){
       List<Orders> list =  orderService.findByCondition(vo);
       return list;
    }

    /**
     * 查看订单详情
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("findOrderDetails")
    public String findOrderDetails(String id ,Model model){
        Orders orders = orderService.findOrderDeatils(id);
        model.addAttribute("order",orders);
        return "/admin/orders/view.jsp";
    }

}
